<?php
/**
 * 后端管理功能
 */
namespace app\controllers;

use Yii;
use yii\base\Controller;
use app\lib\Code;

/**
 */
class BaseController extends Controller
{

    public function beforeAction($action)
    {
        if (! parent::beforeAction($action)) {
            return false;
        }
        $userInfo = Yii::$app->session->get('userInfo');
        $act = $this->module->id . '/' . Yii::$app->controller->id . '/' . Yii::$app->controller->action->id;
        if (! in_array($act, Yii::$app->params['auth_onacess']) && ! $userInfo) {
           // formatJson(Code::AUTH);
        }
        // other custom code here
        return true; // or false to not run the action
    }
    // 默认返回正常数据
    public function afterAction($action, $result)
    {
        $result = parent::afterAction($action, $result);
        formatJson(Code::SUCCESS, '', $result);
        // your custom code here
        return $result;
    }
}